#ifndef CAPTURETHREAD_H
#define CAPTURETHREAD_H

#include <QThread>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <QMutex>
#include <QTime>
#include <vector>
#include <iostream>

using namespace cv;
using namespace std;

typedef struct {
    Mat image;
    int dtime;
} Frame;

class CaptureThread : public QThread {
    Q_OBJECT

public:
    explicit CaptureThread(QObject *parent = 0);
    void     stop();
    bool     connect_localcamera(int dev);
    bool     connect_ipcamera(QString ip, QString showable);
    bool     open_video(QString dir);
    bool     running_flag;
    Frame    getFrameAt(int);
    bool     frameExists(int i);
    int      getNoFrames();

private:
    void run();


    VideoCapture    cam;
    Frame           frame;
    QMutex          istheEnd;
    bool            is_connected;
    vector<Frame>   frames;
    
signals:
    void update_status(QString text);
public slots:
    void save_vector();
};

#endif // CAPTURETHREAD_H
